import static org.junit.Assert.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import junit.framework.TestCase;


public class InventoryTest extends TestCase {
	public CoffeeMaker cm;
	public Inventory i;
	public Recipe r3;

	@Before
	public void setUp() {
		cm = new CoffeeMaker();
		i = cm.checkInventory();

		r3 = new Recipe();
		r3.setName("Coffee");
		r3.setPrice(50);
		r3.setAmtCoffee(2);
		r3.setAmtMilk(2);
		r3.setAmtSugar(2);
		r3.setAmtChocolate(2);
	}
	@After
	public void tearDown() throws Exception {
		cm = null;
		i = null;
		r3 = null;
	}

	@Test
	public void testAddInventory1() {
		int amtCoffee = 1;
		int amtMilk = 1;
		int amtSugar = 1;
		int amtChocolate = 1;
		
		cm.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		
		assertEquals(16, i.getCoffee(), 0);
	}
	
	@Test
	public void testSetChocolate1() {
		i.setChocolate(-1);
		assertEquals(0,i.getChocolate(),0);
	}

	@Test
	public void testSetCoffee1() {
		i.setCoffee(-1);
		assertEquals(0,i.getCoffee(),0);
	}
	
	
	@Test
	public void testSetMilk1() {
		i.setMilk(-1);
		assertEquals(0,i.getMilk(),0);
	}
	
	@Test
	public void testSetSugar1() {
		i.setSugar(-1);
		assertEquals(0,i.getSugar(),0);
	}
	
	@Test
	public void testEnoughIngredientsCoffee1() {
		i.setCoffee(1);
		i.setChocolate(2);
		i.setMilk(2);
		i.setSugar(2);
		i.enoughIngredients(r3);
		assertFalse(false);
	}
	
	public void testEnoughIngredientsCoffee2() {
		i.setCoffee(2);
		i.setChocolate(2);
		i.setMilk(2);
		i.setSugar(2);
		assertTrue(i.enoughIngredients(r3));
	}
	
	@Test
	public void testEnoughIngredientsMilk1() {
		i.setCoffee(2);
		i.setChocolate(2);
		i.setMilk(1);
		i.setSugar(2);
		i.enoughIngredients(r3);
		assertFalse(false);
	}
	
	@Test
	public void testEnoughIngredientsSugar1() {
		i.setCoffee(2);
		i.setChocolate(2);
		i.setMilk(2);
		i.setSugar(1);
		i.enoughIngredients(r3);
		assertFalse(false);
	}
	
	@Test
	public void testEnoughIngredientsChocolate1() {
		i.setCoffee(2);
		i.setChocolate(1);
		i.setMilk(2);
		i.setSugar(2);
		i.enoughIngredients(r3);
		assertFalse(false);
	}

	@Test
	public void testToString1() {
		int amtCoffee = 1;
		int amtMilk = 1;
		int amtSugar = 1;
		int amtChocolate = 1;
		String result;
		cm.addInventory(amtCoffee, amtMilk, amtSugar, amtChocolate);
		
        Inventory inventory = cm.checkInventory();
        result = inventory.toString();
        assertEquals("Coffee: 16\nMilk: 16\nSugar: 16\nChocolate: 16\n",result);
	}
	
	@Test
	public void testToString2() {
		  assertNotNull(r3.toString());
	}
	
}
